package com.wuzhuo.information.mapper;

import com.wuzhuo.information.pojo.Message;
import com.wuzhuo.information.pojo.Messages;
import com.wuzhuo.information.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface messageMapper {

    @Select("select * from message where addressee = #{addressee} or `all` = 1")
    public List<Message> list(String addressee);

    void deleteById(List<Long> ids);

    @Select("select * from message where id = #{id}")
    Message getMessageById(Integer id);

    @Insert("insert into message(date, name, title, remark, content, addressee, `all`) " +
            "VALUES (#{date}, #{name}, #{title}, #{remark}, #{content}, #{addressee}, #{all})")
    void insert(Message message);

    @Update("update message set status = 1 where id = #{id}")
    void changeRead(Integer id);

    @Insert("insert into message(date, name, title, remark, content, addressee, `all`) " +
            "values (#{date}, #{name}, #{title}, #{remark}, #{content}, #{addressee}, #{all})")
    void reply(Message message);

}
